package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.entity.BpEmergencyContingencyPlans;
import com.joysuch.wwyt.bp.entity.BpEmergencyExercisePlan;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

import java.util.Date;
import java.util.List;

public interface BpEmergencyExercisePlanDao extends JpaRepository<BpEmergencyExercisePlan, Long>, QuerydslPredicateExecutor<BpEmergencyExercisePlan> {

    public Page<BpEmergencyExercisePlan> findAll(Specification<BpEmergencyExercisePlan> spec, Pageable pageable);

    List<BpEmergencyExercisePlan> findByName(String name);

    List<BpEmergencyExercisePlan> findByNameAndIdNot(String name,Long id);

    List<BpEmergencyExercisePlan> findByPid(Long id);

    @Query(value = "select * from wwyt_bp_emergency_exercise_plan where START_DATE is not null and  START_DATE between ?1 and ?2 and delete_flag = '0' ",nativeQuery = true)
    List<BpEmergencyExercisePlan>  findExpired(Date startDate, Date endDate);
}
